//package com.plian.system.controller.hr.passport;
//
//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
//import com.baomidou.mybatisplus.core.metadata.IPage;
//import com.plian.Tools.Func;
//import com.plian.Tools.StringPool;
//import com.plian.Tools.TokenUtil;
//import com.plian.Tools.base.BaseController;
//import com.plian.Tools.pagedata.PageData;
//import com.plian.system.config.Resubmit;
//import com.plian.system.constant.sys.FormStatusConstant;
//import com.plian.system.constant.sys.FormTypeConstant;
//import com.plian.system.entity.hr.passport.PassportLend;
//import com.plian.system.model.CommonCode;
//import com.plian.system.model.ListResult;
//import com.plian.system.model.R;
//import com.plian.system.mybatis.search.SearchEntity;
//import com.plian.system.mybatis.search.SearchParamEntiy;
//import com.plian.system.mybatis.support.Condition;
//import com.plian.system.mybatis.support.Query;
//import com.plian.system.service.hr.passport.IPassportLendService;
//import com.plian.system.service.sys.code.IFormCodeService;
//import com.plian.system.service.wf.FormWorkflowService;
//import com.plian.system.vo.hr.passport.PassportLendVO;
//import com.plian.system.wrapper.hr.passport.PassportLendWrapper;
//import lombok.AllArgsConstructor;
//import lombok.extern.slf4j.Slf4j;
//import org.apache.commons.lang3.StringUtils;
//import org.springframework.web.bind.annotation.PostMapping;
//import org.springframework.web.bind.annotation.RequestBody;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RestController;
//
//import javax.validation.Valid;
//import java.util.HashMap;
//import java.util.List;
//
///**
// *  控制器
// *
// * @author gangan
// * @since 2019-12-09
// */
//@Slf4j
//@RestController
//@AllArgsConstructor
//@RequestMapping("api/passportlend")
//public class PassportLendController extends BaseController {
//
//	private IPassportLendService passportLendService;
//
//	private FormWorkflowService formWorkflowService;
//
//	private IFormCodeService formCodeService;
//
//	private PassportLendWrapper passportLendWrapper;
//
//    /**
//    * 详情
//    */
//	@PostMapping("/detail")
//	public R<PassportLendVO> detail(@Valid @RequestBody PassportLend passportLend) {
//		PassportLend detail = passportLendService.getOne(Condition.getQueryWrapper(passportLend));
//		PassportLendVO passportLendVO = passportLendWrapper.entityToVO(detail);
//		return R.data(passportLendVO);
//	}
//
//	/**
//	* 分页
//	*/
//	@PostMapping("/list")
//	public ListResult<PassportLendVO> list(@Valid @RequestBody Query query) {
//		if(query.getAscs()==null&&query.getDescs()==null){
//			query.setDescs("create_time");
//		}
//		List<SearchEntity> entityList = query.getSearch();
//		QueryWrapper<PassportLend> queryWrapper = SearchParamEntiy.getQueryWrapper(
//				Condition.getQueryWrapper(new PassportLend()), entityList
//		);
//		queryWrapper.eq("create_company_id", TokenUtil.getTokenOrgId());
//		IPage<PassportLend> pages = passportLendService.page(Condition.getPage(query), queryWrapper);
//		List<PassportLendVO> passportLendVOS = passportLendWrapper.entityToVO(pages.getRecords());
//		ListResult<PassportLendVO> listResult = new ListResult<>(CommonCode.SUCCESS);
//		listResult.setList(passportLendVOS);
//		listResult.setTotal(Long.valueOf(pages.getTotal()).intValue());
//		return listResult;
//	}
//
//	/**
//	* 新增或修改
//	*/
//	@PostMapping("/submit")
//	@Resubmit(delaySeconds = 0)
//	public R submit(@Valid @RequestBody PassportLend passportLend) {
//		if (passportLend.getId()==null){
//			passportLend.setVersion("1");
//			passportLend.setDef1("未归还");
//			passportLend.setCode(formCodeService.getCode(FormTypeConstant.HR_PASSPORT_LEND_FORM));
//			passportLend.setFormType(String.valueOf(FormTypeConstant.HR_PASSPORT_LEND_FORM));
//		}
//
//		boolean result = passportLendService.saveOrUpdate(passportLend);
//		HashMap<String, Object> processVariable = new HashMap<>();
//		formWorkflowService.startProcessAndSimulate(String.valueOf(passportLend.getId()),passportLend.getFormType(),processVariable);
//
//		return result ? new R(CommonCode.SUCCESS) : new R(CommonCode.FAIL);
//	}
//
//	/**
//	* 删除
//	*/
//	@PostMapping("/remove")
//	public R remove(@RequestBody PageData pd) {
//		List<String> ids = (List<String>)pd.get("ids");
//		return passportLendService.deleteLogic(Func.toLongList(StringUtils.join(ids, StringPool.COMMA)))
//				? new R(CommonCode.SUCCESS) : new R(CommonCode.FAIL);
//	}
//
//
//	/**
//	 * 分页
//	 */
//	@PostMapping("/refList")
//	public ListResult<PassportLendVO> refList(@Valid @RequestBody Query query) {
//		if(query.getAscs()==null&&query.getDescs()==null){
//			query.setDescs("create_time");
//		}
//		List<SearchEntity> entityList = query.getSearch();
//		QueryWrapper<PassportLend> queryWrapper = SearchParamEntiy.getQueryWrapper(
//				Condition.getQueryWrapper(new PassportLend()), entityList
//		);
//		queryWrapper.eq("lender_company", TokenUtil.getTokenOrgId());
//		queryWrapper.eq("status", FormStatusConstant.FINISH);
//		queryWrapper.eq("def1", "未归还");
//		IPage<PassportLend> pages = passportLendService.page(Condition.getPage(query), queryWrapper);
//		List<PassportLendVO> passportLendVOS = passportLendWrapper.entityToVO(pages.getRecords());
//		ListResult<PassportLendVO> listResult = new ListResult<>(CommonCode.SUCCESS);
//		listResult.setList(passportLendVOS);
//		listResult.setTotal(Long.valueOf(pages.getTotal()).intValue());
//		return listResult;
//	}
//
//}
